package com.todod.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.todod.entity.ResultData;
import com.todod.mapper.PublicFileRecordsMapper;
import com.todod.service.PublicFileRecordsService;

/**
 * @author lql
 * @date 2020年12月25日
 */
@RestController
@RequestMapping("/publicFileRecords")
public class PublicFileRecordsController extends BaseManageController {

	@Autowired
	public PublicFileRecordsService publicFileRecordsService;
	@Autowired
	public PublicFileRecordsMapper publicFileRecordsMapper;

	/**
	 * 
	 * @param _userId
	 * @param reqPublicFileRecords
	 * @return
	 */
	@PostMapping("/save")
	public ResultData saveData(@RequestAttribute Long _userId, Long fileId, String flag) {

		publicFileRecordsService.saveData(_userId, fileId, flag);

		return ResultData.success();
	}

	/**
	 * 
	 * @param ids
	 * @return
	 */
	@RequestMapping("/delete")
	public ResultData delete(String ids) {

		String[] id = ids.split(",");
		for (int i = 0; i < id.length; i++) {
			publicFileRecordsMapper.deleteById(id[i]);
		}
		return ResultData.success();
	}

}
